window.onload = function() {
    /* 7、正则 */
    
    var regtel = /^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\d{8}$/;
    var hanzi = /^[\u4e00-\u9fa5]{2,8}$/;  //昵称
    var regmes = /^\d{6}$/;
    var regpwd = /^[a-zA-Z0-9-_]{6,16}$/;
    var pwd = document.querySelector('#pwd');
    var tel = document.querySelector('#tel');
    var mes = document.querySelector('#mes');
    var surepwd = document.querySelector('#surepwd');
    //表单验证的函数
    function regexp(ele,reg) {
        ele.onblur = function() {
            if(reg.test(this.value)){
                this.nextElementSibling.className = 'success';
                this.nextElementSibling.innerHTML = '<i class="success_icon"></i> 输入正确';
            }else {
                this.nextElementSibling.className = 'error';
                this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 格式输入不正确，请重新输入';
            }
        }
    }
    regexp(tel,regtel);//手机号
    regexp(mes,regmes);
    regexp(pwd,regpwd);

    surepwd.onblur = function() {
        if(this.value == pwd.value) {
            this.nextElementSibling.className = 'success';
            this.nextElementSibling.innerHTML = '<i class="success_icon"></i> 输入正确';
        }else {
            this.nextElementSibling.className = 'error';
            this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 密码不一致，请重新输入 ';
        }
    }
}
